Skip to content

Create ChunkedTransaction class#2389

Merged
MonaaEid merged 19 commits into
hiero-ledger:mainfrom
MonaaEid:chore/2300-create-ChunkedTransaction
Jul 14, 2026
Merged

Create ChunkedTransaction class#2389
MonaaEid merged 19 commits into
hiero-ledger:mainfrom
MonaaEid:chore/2300-create-ChunkedTransaction

Conversation

@MonaaEid

Copy link
Copy Markdown
Contributor

Description:
This pull request refactors the chunking and execution logic for both TopicMessageSubmitTransaction and FileAppendTransaction by introducing and leveraging a new ChunkedTransaction base class. The changes simplify and centralize chunking functionality, improve message/content handling, and remove redundant or duplicated code from the transaction classes.

Simplification and cleanup:

  • Removed unused imports and redundant attributes from both transaction files, reducing code complexity.
  • Removed custom validation and execution methods (_validate_chunking, execute, execute_all, etc.) from TopicMessageSubmitTransaction in favor of base class implementations.
  • The sign method is simplified to delegate to the base class and support method chaining.

Related issue(s):

Fixes #2300

Checklist

  • Documented (Code comments, etc.)
  • Tested (unit, integration, etc.)

MonaaEid and others added 2 commits June 26, 2026 01:26
Signed-off-by: MonaaEid <monaa_eid@hotmail.com>
Signed-off-by: MontyPokemon <59332150+MonaaEid@users.noreply.github.com>
@github-actions github-actions Bot added lang: python Uses Python programming language skill: advanced requires knowledge of multiple areas in the codebase without defined steps to implement or examples labels Jun 25, 2026
@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.10145% with 4 lines in your changes missing coverage. Please review.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2389      +/-   ##
==========================================
+ Coverage   94.98%   94.99%   +0.01%     
==========================================
  Files         163      164       +1     
  Lines       10464    10447      -17     
==========================================
- Hits         9939     9924      -15     
+ Misses        525      523       -2     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

MonaaEid and others added 3 commits June 29, 2026 22:29
Signed-off-by: MonaaEid <monaa_eid@hotmail.com>
Signed-off-by: MonaaEid <monaa_eid@hotmail.com>
@MonaaEid
MonaaEid marked this pull request as ready for review June 29, 2026 22:05
@MonaaEid
MonaaEid requested review from a team as code owners June 29, 2026 22:05
@MonaaEid
MonaaEid requested review from Dosik13 and exploreriii June 29, 2026 22:05
@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds ChunkedTransaction to centralize chunked transaction state, validation, signing, sizing, and execution. Migrates topic-message and file-append transactions to the abstraction, adds bytes-aware topic messages, and updates unit and integration coverage.

Changes

Chunked transaction extraction and migration

Layer / File(s) Summary
Shared chunking behavior
src/hiero_sdk_python/transaction/chunked_transaction.py
Defines chunk state, validation, per-chunk transaction IDs, sequential execution, signing-key reuse, and per-chunk body sizing.
Topic message migration
src/hiero_sdk_python/consensus/topic_message_submit_transaction.py
Extends ChunkedTransaction, accepts bytes or str messages, centralizes serialization, delegates chunk configuration, and removes local chunk orchestration.
File append migration
src/hiero_sdk_python/file/file_append_transaction.py
Extends ChunkedTransaction, simplifies initialization, delegates chunk configuration, and updates protobuf restoration state.
Validation and execution coverage
tests/unit/chunked_transaction_test.py, tests/unit/file_append_transaction_test.py, tests/integration/*transaction_e2e_test.py
Tests shared chunk behavior, sequential execution, state restoration, and updated chunk-limit errors and execution paths.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant ChunkedTransaction
  participant Transaction
  Client->>ChunkedTransaction: execute_all(client)
  ChunkedTransaction->>ChunkedTransaction: validate and freeze chunks
  loop each chunk
    ChunkedTransaction->>ChunkedTransaction: select transaction ID and re-sign
    ChunkedTransaction->>Transaction: execute(client)
    Transaction-->>ChunkedTransaction: chunk response
  end
  ChunkedTransaction-->>Client: ordered responses
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 67.92% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: introducing the ChunkedTransaction base class.
Description check ✅ Passed The description matches the refactor and its cleanup goals, so it is clearly related to the changeset.
Linked Issues check ✅ Passed The new ChunkedTransaction base class and refactors cover chunking, freezing, execution, signing, and body-size logic with tests, matching #2300.
Out of Scope Changes check ✅ Passed I don't see unrelated code changes beyond the chunking refactor and corresponding tests.
📋 Issue Planner

Built with CodeRabbit's Coding Plans for faster development and fewer bugs.

View plan used: #2300

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/hiero_sdk_python/consensus/topic_message_submit_transaction.py (1)

189-193: 🩺 Stability & Availability | 🔴 Critical | ⚡ Quick win

BLOCKER: Guard _initial_transaction_id before serializing chunk info.

build_transaction_body() can be called directly on a multi-chunk message before freeze_with(), leaving _initial_transaction_id as None and crashing here. Proto field: chunkInfo.initialTransactionID field 1. Issue type: oneof/wire-format lifecycle null-safety. (github.com)

🐛 Suggested fix
         # Multi-chunk metadata
         if self._total_chunks > 1:
+            if self._initial_transaction_id is None:
+                raise ValueError(
+                    "Initial transaction ID must be set before building a multi-chunk topic message. "
+                    "Call freeze_with(client) first."
+                )
             body.chunkInfo.CopyFrom(
                 consensus_submit_message_pb2.ConsensusMessageChunkInfo(
                     initialTransactionID=self._initial_transaction_id._to_proto(),

As per path instructions, "_build_proto_body() calls self._initial_transaction_id._to_proto() when _total_chunks > 1 ... an explicit guard with a descriptive ValueError MUST be present."

Source: Path instructions


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 563e667a-6375-4f1a-bc84-abfff5273cb8

📥 Commits

Reviewing files that changed from the base of the PR and between 2f1705a and 04c4496.

📒 Files selected for processing (5)
  • src/hiero_sdk_python/consensus/topic_message_submit_transaction.py
  • src/hiero_sdk_python/file/file_append_transaction.py
  • src/hiero_sdk_python/transaction/chunked_transaction.py
  • tests/integration/topic_message_submit_transaction_e2e_test.py
  • tests/unit/chunked_transaction_test.py

Comment thread src/hiero_sdk_python/file/file_append_transaction.py Outdated
Comment thread tests/integration/topic_message_submit_transaction_e2e_test.py Outdated
Comment thread tests/unit/chunked_transaction_test.py
Comment thread tests/unit/chunked_transaction_test.py
@github-actions github-actions Bot added open to community review PR is open for community review and feedback queue:junior-committer PR awaiting initial quality review labels Jun 29, 2026
Comment thread src/hiero_sdk_python/transaction/chunked_transaction.py Outdated
Comment thread src/hiero_sdk_python/transaction/chunked_transaction.py Outdated
Comment thread src/hiero_sdk_python/transaction/chunked_transaction.py
Comment thread src/hiero_sdk_python/transaction/chunked_transaction.py Outdated
Comment thread src/hiero_sdk_python/transaction/chunked_transaction.py Outdated
Comment thread tests/integration/topic_message_submit_transaction_e2e_test.py Outdated
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

Hello, this is the OfficeHourBot.

This is a reminder that the Hiero Python SDK Office Hours will begin in approximately 2 hours and 57 minutes (14:00 UTC).

This session provides an opportunity to ask questions regarding this Pull Request.

Details:

Disclaimer: This is an automated reminder. Please verify the schedule here for any changes.

From,
The Python SDK Team

@MonaaEid
MonaaEid marked this pull request as draft July 4, 2026 14:45
@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown

Hi, this is WorkflowBot.
Your pull request cannot be merged as it is not passing all our workflow checks.
Please click on each check to review the logs and resolve issues so all checks pass.
To help you:

MonaaEid added 2 commits July 4, 2026 19:16
Signed-off-by: MonaaEid <monaa_eid@hotmail.com>
Signed-off-by: MonaaEid <monaa_eid@hotmail.com>
@MonaaEid
MonaaEid force-pushed the chore/2300-create-ChunkedTransaction branch from 02d3111 to f8bd8cf Compare July 4, 2026 16:17
MonaaEid and others added 3 commits July 4, 2026 19:27
Signed-off-by: MonaaEid <monaa_eid@hotmail.com>
Signed-off-by: MonaaEid <monaa_eid@hotmail.com>
@MonaaEid
MonaaEid marked this pull request as ready for review July 4, 2026 16:56
@github-actions github-actions Bot added the queue:junior-committer PR awaiting initial quality review label Jul 12, 2026
@aceppaluni aceppaluni added the status: update branch developer needs to click update branch label Jul 13, 2026
Comment thread tests/unit/chunked_transaction_test.py
exploreriii
exploreriii previously approved these changes Jul 14, 2026
@github-actions github-actions Bot added queue:committers PR awaiting committer technical review and removed queue:junior-committer PR awaiting initial quality review labels Jul 14, 2026
Signed-off-by: MonaaEid <monaa_eid@hotmail.com>
@MonaaEid
MonaaEid force-pushed the chore/2300-create-ChunkedTransaction branch from cac35b2 to c6d2eba Compare July 14, 2026 16:18
@MonaaEid
MonaaEid requested a review from exploreriii July 14, 2026 16:19
@MonaaEid MonaaEid added this to the v0.2.9 milestone Jul 14, 2026
@github-actions github-actions Bot added queue:junior-committer PR awaiting initial quality review and removed queue:committers PR awaiting committer technical review labels Jul 14, 2026
@github-actions github-actions Bot added queue:committers PR awaiting committer technical review and removed queue:junior-committer PR awaiting initial quality review labels Jul 14, 2026

@manishdait manishdait left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks @MonaaEid, please update the branch

@github-actions github-actions Bot added status: ready-to-merge PR has 1+ maintainer and 2+ total approvals, ready to merge and removed queue:committers PR awaiting committer technical review labels Jul 14, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 47ad9cf2-88bb-4801-b98e-d8ef00433358

📥 Commits

Reviewing files that changed from the base of the PR and between fd9f4f0 and 565ed51.

📒 Files selected for processing (2)
  • tests/integration/file_append_transaction_e2e_test.py
  • tests/unit/chunked_transaction_test.py

Comment thread tests/integration/file_append_transaction_e2e_test.py
@MonaaEid
MonaaEid merged commit df3bd1e into hiero-ledger:main Jul 14, 2026
33 of 45 checks passed
@github-actions

Copy link
Copy Markdown

👋 Hi @MonaaEid! Great work completing a Advanced issue! 🎉

Thanks for your contribution! 🚀

Here are some issues you might want to explore next:

🌟 Stay connected:

Happy coding! 🚀
— Hiero Python SDK Team

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lang: python Uses Python programming language open to community review PR is open for community review and feedback skill: advanced requires knowledge of multiple areas in the codebase without defined steps to implement or examples status: ready-to-merge PR has 1+ maintainer and 2+ total approvals, ready to merge status: update branch developer needs to click update branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create an abstract ChunkedTransaction base class to centralize chunking transaction logic

7 participants